

#include <iostream>
#include <string>
//#include <ctype.h>
#include <cctype>
#include <algorithm>

// void test_case1() {
    
//     std::string str("acdeft");

//     std::string str1;
//     //char str[]="Test String.\n";


//     for (int i = 0; i < 5; i++) {
//         str1[i] = std::toupper(static_cast<int>(str[i]));
//     }

//     std::cout << str << std::endl;
//     std::cout << str1 << std::endl;

// }

using namespace std;

void test_case2() {

    string str = "THIS IS A STRING";
    for (size_t i = 0; i < str.size(); i++) {
       str[i] = static_cast<char>(std::tolower(str[i]));//把大写全部转为小写

    }
    cout<<str<<endl;


    for (char ch : str) 
        cout << ch << endl;

}

void test_case3() {

    string my_str = "Hello WORLD";
    cout << "Main string: " << my_str << endl;
    transform(my_str.begin(), my_str.end(), my_str.begin(), ::tolower);
    cout << "Converted String: " << my_str;
}

void test_case4() {

    string my_str = "Hello WORLD";
    cout << "Main string: " << my_str << endl;

    for_each(my_str.begin(), my_str.end(), [](char& ch) {
        ch = static_cast<char>(std::tolower(ch));
    });
    cout << "Converted String: " << my_str;

}

void test_case5() {

    wstring wstr1 = L"宽字符串类";
    wcout << wstr1 << endl;

    basic_string<wchar_t> wstr2 = L"hello wchar string";
    wcout << wstr2 << endl;
}

void test_case6() {
    
    string my_str = "Hello WORLD";
    cout << "Main string: " << my_str << endl;
    string out_str;
    for (char ch : my_str) {
        out_str += static_cast<char>(std::toupper(ch));
    }
    cout << "Converted String: " << out_str;
}

void test_case7() {
    string my_str = "Hello WORLD";
    std::cout << std::boolalpha;

    for (char ch : my_str) {
        cout << ch << " is alnum " << ::isalnum(ch) << endl;
    }
}
int main() {

    // test_case2();
    // test_case3();
    // test_case4();
    // test_case5();

    test_case7();

    return 0;

}